// MIT License
// 开源地址：https://gitee.com/co1024/AbcMvc
// Copyright (c) 2021-2023 1024
// Abc.Mvc=Furion+EF+SqlSugar+Pear layui admin.

namespace Abc.Utils;

/// <summary>
/// 分页参数
/// </summary>
public class PagedBaseQuery
{
    /// <summary>
    /// 页数
    /// </summary>
    private int _pageIndex = 1;

    /// <summary>
    /// 页数
    /// </summary>
    public int PageIndex
    {
        get
        {
            if (_pageIndex > 0)
            {
                return _pageIndex;
            }
            return 1;
        }
        set => _pageIndex = value;
    }

    /// <summary>
    /// 每页条数
    /// </summary>
    private int _pageSize = 10;

    /// <summary>
    /// 每页条数
    /// </summary>
    public int PageSize
    {
        get
        {
            if (_pageSize > 0)
            {
                return _pageSize;
            }
            return 10;
        }
        set => _pageSize = value;
    }

    /// <summary>
    /// 排序类型，默认倒序
    /// </summary>
    public SqlSugar.OrderByType OrderByType { get; set; } = SqlSugar.OrderByType.Desc;
    /// <summary>
    /// 排序字段，默认为空
    /// </summary>
    [MaxLength(50, ErrorMessage = "排序字段长度不能超过50个字符")]
    public string SortField { get; set; } = "";
}